package com.ysqcould.web.controller.allocation;


import com.ysqcould.allocation.domain.JbFinanceConfig;
import com.ysqcould.allocation.domain.WxUserContacts;
import com.ysqcould.allocation.service.IJbFinanceConfigService;
import com.ysqcould.common.annotation.Log;
import com.ysqcould.common.core.controller.BaseController;
import com.ysqcould.common.core.domain.AjaxResult;
import com.ysqcould.common.core.page.TableDataInfo;
import com.ysqcould.common.enums.BusinessType;
import com.ysqcould.common.utils.poi.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 数据大屏Controller
 * 
 * @author ruoyi
 * @date 2022-06-30
 */
@RestController
@RequestMapping("/allocation/fconfig")
public class JbFinanceConfigController extends BaseController
{
    @Autowired
    private IJbFinanceConfigService jbFinanceConfigService;

    /**
     * 查询数据大屏列表
     */
    @PreAuthorize("@ss.hasPermi('allocation:fconfig:list')")
    @GetMapping("/list")
    public TableDataInfo list(JbFinanceConfig jbFinanceConfig)
    {
        startPage();
        List<JbFinanceConfig> list = jbFinanceConfigService.selectJbFinanceConfigList(jbFinanceConfig);
        return getDataTable(list);
    }

    /**
     * 导出数据大屏列表
     */
    @PreAuthorize("@ss.hasPermi('allocation:fconfig:export')")
    @Log(title = "数据大屏", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, JbFinanceConfig jbFinanceConfig)
    {
        List<JbFinanceConfig> list = jbFinanceConfigService.selectJbFinanceConfigList(jbFinanceConfig);
        ExcelUtil<JbFinanceConfig> util = new ExcelUtil<JbFinanceConfig>(JbFinanceConfig.class);
        util.exportExcel(response, list, "数据大屏数据");
    }

    /**
     * 获取数据大屏详细信息
     */
    @PreAuthorize("@ss.hasPermi('allocation:fconfig:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(jbFinanceConfigService.selectJbFinanceConfigById(id));
    }

    /**
     * 新增数据大屏
     */
    @PreAuthorize("@ss.hasPermi('allocation:fconfig:add')")
    @Log(title = "数据大屏", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody JbFinanceConfig jbFinanceConfig)
    {
        jbFinanceConfig.setAsId(getUserId());
        return toAjax(jbFinanceConfigService.insertJbFinanceConfig(jbFinanceConfig));
    }

    /**
     * 修改数据大屏
     */
    @PreAuthorize("@ss.hasPermi('allocation:fconfig:edit')")
    @Log(title = "数据大屏", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody JbFinanceConfig jbFinanceConfig)
    {
        return toAjax(jbFinanceConfigService.updateJbFinanceConfig(jbFinanceConfig));
    }

    /**
     * 删除数据大屏
     */
    @PreAuthorize("@ss.hasPermi('allocation:fconfig:remove')")
    @Log(title = "数据大屏", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(jbFinanceConfigService.deleteJbFinanceConfigByIds(ids));
    }

    /**
     * 状态修改
     */
    @Log(title = "通信录", businessType = BusinessType.UPDATE)
    @PutMapping("/changeStatus")
    public AjaxResult changeStatus(@RequestBody JbFinanceConfig financeConfig)
    {
        return toAjax(jbFinanceConfigService.updateStatus(financeConfig));
    }
}
